#include <opencv2/opencv.hpp>
#include <iostream>

int main(int argc, char** argv) {
    // 检查参数是否合法
    if (argc != 2) {
        std::cout << "Usage: ./display_image <2.png>\n";
        return -1;
    }

    // 读取图片文件
    cv::Mat image = cv::imread(argv[1], cv::IMREAD_COLOR);
    if (image.empty()) {
        std::cerr << "Error: Could not load image at " << argv[1] << std::endl;
        return -1;
    }

    // 创建窗口并显示
    cv::namedWindow("OpenCV Image Viewer", cv::WINDOW_AUTOSIZE);
    cv::imshow("OpenCV Image Viewer", image);
    
    // 等待按键输入后退出
    cv::waitKey(0);
    return 0;
}

